//BusClearingOrderRealationModel
//2020-08-24 15:20:46

package models

import (
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/base/common/models/base"
	"git.900sui.cn/kc/kcgin/orm"
)

//表结构体
type BusClearingOrderRealationModel struct {
	Model *base.Model
	Field BusClearingOrderRealationModelField
}

//表字段
type BusClearingOrderRealationModelField struct {
	T_table       string `default:"bus_clearing_order_realation"`
	F_id          string `default:"id"`
	F_clear_id    string `default:"clear_id"`
	F_order_sn    string `default:"order_sn"`
	F_pay_sn      string `default:"pay_sn"`
	F_create_time string `default:"create_time"`
}

//初始化
func (b *BusClearingOrderRealationModel) Init(ormer ...orm.Ormer) *BusClearingOrderRealationModel {
	functions.ReflectModel(&b.Field)
	b.Model = base.NewModel(b.Field.T_table, ormer...)
	return b
}

//新增数据
func (b *BusClearingOrderRealationModel) Insert(data map[string]interface{}) int {
	result, _ := b.Model.Data(data).Insert()
	return result
}

//根据订单号获取信息
func (b *BusClearingOrderRealationModel) GetByOrderSn(orderSn string) map[string]interface{} {
	if len(orderSn) == 0{
		return map[string]interface{}{}
	}
	return b.Model.Where([]base.WhereItem{
		{
			Field: b.Field.F_order_sn,
			Value: orderSn,
		},
	}).Limit(0,1 ).Find()

}
